Polytypic Programming With Ease

نویسنده

  • Ralf Hinze
چکیده

A functional polytypic program is one that is parameterised by datatype. Since poly-typic functions are deened by induction on types rather than by induction on values they typically operate on a higher level of abstraction than their monotypic counterparts. However, polytypic programming is not necessarily more complicated than conventional programming. We show that a polytypic function is uniquely deened by its action on constant functors, projection functors, sums, and products. This information is suucient to specialize a polytypic function to arbitrary polymorphic datatypes, including mutually recursive datatypes and nested datatypes. The key idea is to use innnite trees as index sets for polytypic functions and to interpret datatypes as algebraic trees. This approach appears both to be simpler, more general, and more eecient than previous ones which are based on the initial algebra semantics of datatypes. Polytypic functions enjoy polytypic properties. We show that well-known properties of various functions are obtained as direct consequences of two general polytypic fusion laws.

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Type-safe run-time polytypic programming

Polytypic programming is a way of defining type-indexed operations, such as map, fold and zip, based on type information. Run-time polytypic programming allows that type information to be dynamically computed—this support is essential in modern programming languages that support separate compilation, first-class type abstraction, or polymorphic recursion. However, in previous work we defined ru...

متن کامل

Polytypic Functional Programming

Structural polymorphism is a generic programming technique known within the functional programming community under the names of polytypic or datatype-generic programming. In this thesis we show that such a technique conflicts with the principle of data abstraction and propose a solution for reconciliation. More concretely, we show that popular polytypic extensions of the functional programming ...

متن کامل

Polytypic Programming

Many functions have to be written over and over again for different datatypes, either because datatypes change during the development of programs, or because functions with similar functionality are needed on diierent datatypes. Examples of such functions are pretty printers, debug-gers, equality functions, uniiers, pattern matchers, rewriting functions, etc. Such functions are called polytypic...

متن کامل

Formal polytypic programs and proofs

The aim of our work is to be able to do fully formal, machine verified proofs over Generic Haskellstyle polytypic programs. In order to achieve this goal, we embed polytypic programming in the proof assistant Coq and provide an infrastructure for polytypic proofs. Polytypic functions are reified within Coq as a datatype and they can then be specialized by applying a dependently typed term speci...

متن کامل

Polytypic Functions Over Nested Datatypes

The theory and practice of polytypic programming is intimately connected with the initial algebra semantics of datatypes. This is both a blessing and a curse. It is a blessing because the underlying theory is beautiful and well developed. It is a curse because the initial algebra semantics is restricted to so-called regular datatypes. Recent work by R. Bird and L. Meertens [3] on the semantics ...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:
  • Journal of Functional and Logic Programming

دوره 2001  شماره 

صفحات  -

تاریخ انتشار 2001